﻿using UnityEngine;
using System.Collections;

public static class LineRender
{
	static LineRender()
	{
		m_lineMaterial = new Material("Shader \"Lines/Colored Blended\" {" +
			"SubShader { Pass { " +
			"    Blend SrcAlpha OneMinusSrcAlpha " +
			"    ZWrite Off Cull Off Fog { Mode Off } " +
			"    BindChannels {" +
			"      Bind \"vertex\", vertex Bind \"color\", color }" +
			"} } }");
		m_lineMaterial.hideFlags = HideFlags.HideAndDontSave;
		m_lineMaterial.shader.hideFlags = HideFlags.HideAndDontSave;
	}

	public static void Draw(Color color, Vector3 start, Vector3 end)
	{
		GL.PushMatrix();

		m_lineMaterial.SetPass(0);

		GL.Begin(GL.LINES);
		GL.Color(color);
		GL.Vertex3(start.x, start.y, start.z);
		GL.Vertex3(end.x, end.y, end.z);
		GL.End();

		GL.PopMatrix();
	}

	private static Material m_lineMaterial = null;
}